# 指定最小版本要求: 3.10
cmake_minimum_required(VERSION 3.10.0)
# export LD_LIBRARY_PATH=/home/yuanyou/xun_fei/abdominalmotorServer/lib/:$LD_LIBRARY_PATH

# 指定工程名
project(ABDOMINALMOTORSERVER)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

# 添加头文件搜索路径
include_directories(./include)

# 添加库文件搜索路径
link_directories(./lib)

# 添加编译参数
add_compile_options(-Wall -O2)

# 设置输出路径
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/../bin)

# 查找 pthread
#find_package(Threads REQUIRED)
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)

# 创建可执行文件并命名
add_executable(main_cmake ./src/main.cpp ./src/mode_chose.cpp)

set(CMAKE_THREAD_LIBS_INIT "-lpthread")

# 链接动态库
target_link_libraries(main_cmake
    # 如果显示无法找到相关动态库, 可将一下动态库打开
    # controlcan
    # cyhcs_log
    # eu_canable
    # nl-route-3
    # nl-3
    eu_harmonic
    # Threads::Threads  # 确保 pthread 被链接
)

